﻿using System;
using System.Collections.Generic;
using DATA.Base;
using DATA.BusinessObjects;
using DATA.ManagerObjects;
using NHibernate;

namespace BUS
{
    public class PhuThuBUS
    {
        #region Bình - Lấy phụ thu
        public static IList<Phuthu> LayPhuThu()
        {
            IList<Phuthu> list = null;
            IManagerFactory MF = new ManagerFactory();
            IPhuthuManager PTM = MF.GetPhuthuManager();

            list = PTM.GetAll();
            return list;
        }
        #endregion

        #region Bình - Cập nhật phụ thu
        public static Boolean CapNhatPhuThu(Phuthu pt)
        {
            Boolean flag = false;
            ISession isession = NHibernateSessionManager.Instance.Session.GetISession();
            ITransaction iTrans = null;
            try
            {
                iTrans = isession.BeginTransaction();
                isession.Update(pt);
                iTrans.Commit();
                flag = true;
            }
            catch (Exception ex)
            {
                iTrans.Rollback();
                throw new Exception("Lỗi", ex);
            }
            return flag;
        }
        #endregion
    }
}
